/*
 *  Copyright 2019-2025 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package me.zhengjie.log.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import me.zhengjie.log.dao.LogDao;
import lombok.RequiredArgsConstructor;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import me.zhengjie.log.service.LogService;
import me.zhengjie.log.dao.dto.LogQueryCriteria;
import me.zhengjie.log.LogMapper;
import me.zhengjie.log.utils.PageResult;
import me.zhengjie.log.utils.PageUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Timestamp;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.stream.Collectors;


@Service
@RequiredArgsConstructor
public class LogServiceImpl extends ServiceImpl<LogMapper, LogDao> implements LogService {

    private final LogMapper logMapper;



    @Override
    @Transactional(rollbackFor = Exception.class)
    public void create(LogDao resources) {
        logMapper.insert(resources);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(LogDao resources) {
        LogDao logDao = getById(resources.getLogId());
        logDao.copy(resources);
        logMapper.updateById(logDao);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateData(LogDao resources) {
        LambdaUpdateWrapper<LogDao> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(LogDao::getLogId, resources.getLogId());
        this.update(resources, updateWrapper);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteAll(List<Long> ids) {
        logMapper.deleteBatchIds(ids);
    }





}